<template>
  <el-main>
    <el-card>
      <!-- 添加页面标题 -->
      <div class="page-header">
        <div class="page-title">消息推送设置</div>
        <div class="page-subtitle">钉钉消息推送配置</div>
      </div>
      
      <el-form label-width="100px" style="max-width:500px;">
        <el-form-item label="推送内容">
          <el-input type="textarea" v-model="form.content" placeholder="请输入推送内容" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="sendToDingTalk">推送到钉钉</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </el-main>
</template>

<script>
export default {
  data() {
    return {
      form: { content: '' }
    }
  },
  methods: {
    async sendToDingTalk() {
      if (!this.form.content) {
        this.$message.error('请填写推送内容');
        return;
      }
      try {
        const res = await fetch('https://hellowodingtalk-lsmprvoblr.cn-beijing.fcapp.run', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ content: this.form.content })
        });
        const data = await res.json();
        if (data.errcode === 0) {
          this.$message.success('推送成功！');
        } else {
          this.$message.error('推送失败：' + data.errmsg);
        }
      } catch (e) {
        this.$message.error('推送异常：' + e.message);
      }
    }
  }
}
</script>

<style scoped>
/* 页面标题样式 */
.page-header {
  margin-bottom: 20px;
  text-align: center;
}

.page-title {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.page-subtitle {
  font-size: 16px;
  color: #666;
}

/* 按钮样式 */
.el-button[type="primary"] {
  font-weight: 600;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 6px;
  gap: 6px;
  height: 36px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #409eff 0%, #337ecc 100%);
  border: 1px solid #409eff;
  color: white;
}

.el-button[type="primary"]:hover {
  background: linear-gradient(135deg, #337ecc 0%, #2d5aa0 100%);
  border-color: #337ecc;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(64, 158, 255, 0.3);
}

/* 确保按钮内容居中 */
.el-button .el-button__content {
  display: flex;
  justify-content: center;
  align-items: center;
}

@media (max-width: 700px) {
  .el-main {
    padding: 4px !important;
  }
  .page-header {
    text-align: left;
    padding-left: 10px;
    padding-bottom: 5px;
  }
  .page-title {
    font-size: 20px;
  }
  .page-subtitle {
    font-size: 14px;
  }
  .el-button, .el-input, .el-select {
    font-size: 16px !important;
    min-height: 38px !important;
  }
  .el-form-item__label {
    font-size: 15px !important;
  }
}
</style>
